package com.lk.basic.service.impl;

import com.lk.basic.service.IBaiduAuditService;
import com.lk.basic.util.AjaxResult;
import com.lk.basic.util.BaiduAuditUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class BaiduAuditServiceImpl implements IBaiduAuditService {
    @Override
    public AjaxResult audit(String text, String imgUrl, String videoUrl) {
        AjaxResult result=AjaxResult.me();
        StringBuffer stringBuffer=new StringBuffer();

        if (!StringUtils.isEmpty(text)){
            Map<String,Object> map = BaiduAuditUtils.TextCensor(text);
            Boolean flag = (Boolean) map.get("success");
            if (!flag){
                stringBuffer.append(text+":"+map.get("message"));
            }
        }
        if (!StringUtils.isEmpty(imgUrl)){
            Map<String,Object> map=BaiduAuditUtils.ImgCensor(imgUrl);
            Boolean flag = (Boolean) map.get("message");
            if (!flag){
                stringBuffer.append(text+":"+map.get("message"));
            }
        }
        if (!StringUtils.isEmpty(videoUrl)){

        }
        if (StringUtils.isEmpty(stringBuffer.toString())){
            return AjaxResult.me();
        }
        return AjaxResult.me().setSuccess(false).setMessage(stringBuffer.toString());
    }
}
